﻿using System;
using System.Web;
using System.Web.Security;
using System.Configuration;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Data;
using System.Data.SqlClient;

/// <summary>
///SqlHelper 的摘要说明
/// </summary>
public class SqlHelper
{
    private static readonly string ConnectionString = ConfigurationManager.ConnectionStrings["Connectionstring"].ConnectionString;
    SqlConnection myconnection = new SqlConnection(ConnectionString);

	public SqlHelper()
	{
		//
		//TODO: 在此处添加构造函数逻辑
		//
        myconnection.Open();
	}

    public SqlCommand GetCommand(string CmdText, params SqlParameter[] MyPara)
    {
        SqlCommand mycommand = new SqlCommand();
        mycommand.Connection = myconnection;
        mycommand.CommandText = CmdText;
        mycommand.CommandType = CommandType.Text;
        if (MyPara != null)
        {
            foreach (SqlParameter para in MyPara)
            {
                mycommand.Parameters.Add(para);
            }
        }
        return mycommand;
    }
}
